package com.lnkj.wzhr.util

import android.content.Context
import com.lnkj.spcj.util.Constants
import com.lnkj.spcj.util.utilcode.ToastUtils
import com.tencent.mm.opensdk.modelmsg.SendAuth
import com.tencent.mm.opensdk.openapi.WXAPIFactory

/**
 * Copyright (c) 山东六牛网络科技有限公司 https://liuniukeji.com
 *
 * @Description
 * @Author         与天同行的观测者
 * @Copyright      Copyright (c) 山东六牛网络科技有限公司 保留所有版权(https://www.liuniukeji.com)
 * @Date           $date$ $time$
 */
class ThirdUtils(var context: Context) {

    var iwxapi = WXAPIFactory.createWXAPI(context, Constants.WX_APP_ID, false)

    companion object {

        fun newInstance(context: Context): ThirdUtils {
            val mThirdUtils = ThirdUtils(context)
            return mThirdUtils
        }
    }

    fun wxLogin() {
        iwxapi.registerApp(Constants.WX_APP_ID)
        if (!iwxapi.isWXAppInstalled) {
            ToastUtils.showShort("请先安装微信")
        } else {
            var req = SendAuth.Req()
            req.scope = "snsapi_userinfo"
            req.state = "none"
            iwxapi.sendReq(req)

        }
    }
}